package com.atguigu.yygh.common.exception;

import com.atguigu.yygh.common.result.ResultCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class YyghException extends RuntimeException{


    //状态码
    private Integer code;

    //消息
    private String msg;

    public YyghException(Integer code, String msg, Throwable cause){
        super(cause);
        this.code = code;
        this.msg = msg;
    }

    public YyghException(ResultCodeEnum resultCodeEnum){
        this.code = resultCodeEnum.getCode();
        this.msg = resultCodeEnum.getMessage();
    }

    public YyghException(ResultCodeEnum resultCodeEnum, Throwable cause){
        super(cause);
        this.code = resultCodeEnum.getCode();
        this.msg = resultCodeEnum.getMessage();
    }
}
